﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotNetExtensions.Core.Encryptions;

namespace CoreSimple
{
    public class PKCS1_Simple
    {
        public PKCS1_Simple()
        {
            PKCS1 pKCS1 = new PKCS1(Encoding.Unicode, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgtzYaj4zB1G36FlNYtSgHWTcKyA1D8M9ekzt+lZ5xOWtI9b3Yr8HyJWmtZD2c+N0KAHKqddmrXLuA5gyR2eRxvSHuk3RRY1jo5g1Zr01NE417G9T+aIjyPMuCXHftDxu/aNgY2es2kB4worIvUgBDWZkFKIQ5i6dBr3O7TlRZ6spcxSfQnX7duuLLMzjOUwXcHTEIjg+QV0T7qkY/vPGCtAv1aPkpoFwh1pj9nMnPwKEfRJ3Ra+GZXPmxbDyggu9ylUbwVCoOgj5h5DIgDdBKnxXeq5rH4HCa7j2TtqtQqb3HDzTDv/pVMqfBLtSb1P4tG7g58tUSyeoPDAJeqEVqQIDAQAB", "MIIEogIBAAKCAQEAgtzYaj4zB1G36FlNYtSgHWTcKyA1D8M9ekzt+lZ5xOWtI9b3Yr8HyJWmtZD2c+N0KAHKqddmrXLuA5gyR2eRxvSHuk3RRY1jo5g1Zr01NE417G9T+aIjyPMuCXHftDxu/aNgY2es2kB4worIvUgBDWZkFKIQ5i6dBr3O7TlRZ6spcxSfQnX7duuLLMzjOUwXcHTEIjg+QV0T7qkY/vPGCtAv1aPkpoFwh1pj9nMnPwKEfRJ3Ra+GZXPmxbDyggu9ylUbwVCoOgj5h5DIgDdBKnxXeq5rH4HCa7j2TtqtQqb3HDzTDv/pVMqfBLtSb1P4tG7g58tUSyeoPDAJeqEVqQIDAQABAoIBAGAkiuc7fVgSRLBy87T5jA0sbclNZ06GXaN945V5dQsgxty+8Y/d04Ud1ZYtw7OO12cRMekoNOqXtqBzb/Uf9W0beKB6zZZw81Rc3lb2CaG9GEb139dWtT3M0/Ticb1EbTLxlj5SDB9p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e1 = pKCS1.Encrypt("hello world!>>>LO*", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string e2 = pKCS1.Encrypt("你好哇，阿鲁哇", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string e3 = pKCS1.Encrypt("来个表情，😍🤦‍♀️🎉💋😉💖💖", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);

            string d1 = pKCS1.Decrypt(e1, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string d2 = pKCS1.Decrypt(e2, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string d3 = pKCS1.Decrypt(e3, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);

            Console.WriteLine(d1);
            Console.WriteLine(d2);
            Console.WriteLine(d3);
        }
    }

    public class PKCS8_Simple
    {
        public PKCS8_Simple()
        {
            PKCS8 pKCS1 = new PKCS8(Encoding.Unicode, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoiB9J+5D2ibcSAavTbUvDz1i5SALilDetqKrDzWXH+CieGEPQxrvudHdefy/oWUeRFq7V/wYo/eH3Zsy41FoTdcPp+qHiKmei6ezpb3ORBniDcbahxuCdXDlLNh/7kHofxpWOskvnpsbY/+RGbgMc2HWPPM7GdfovDAbUEmKRz9EUmLSSfxg5J3KwPhqm6rx3pzC8NmTtCMjrSLgKJtSMjM8/+Osj7xp/riI3oWlCKYcB/RBuleeAoPRWwpiJJKOdqUMtEkLdEkCi+dngf4MAxL2CM9inIh9lOlhpiC47LSDnaL4fDT+qI0JkUocwM9B40gTNHb3k4hmYOdFLXX3xwIDAQAB", "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCiIH0n7kPaJtxIBq9NtS8PPWLlIAuKUN62oqsPNZcf4KJ4YQ9DGu+50d15/L+hZR5EWrtX/Bij94fdmzLjUWhN1w+n6oeIqZ6Lp7Olvc5EGeINxtqHG4J1cOUs2H/uQeh/GlY6y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AoGAbnyOiJ4urno/QXyQo+mA6bvhGNCbr8QZRb/uGKR1/8/ZAKVn94Roes3chhN/IWRBb5874ej3tbRWK8jpopbS3ta3u7oKihGHpkELygWwskxXMpKL5P6gFOPSvEtwt5w3bZWOEWFj3uwGuJczkxo6jXEpBed7K/wzx1hz3An5uLECgYEAjPl/KTeVqh33n+s0BREbkflEZHAgSRr/jX5YMSzGQaTnmDVIbVIUwznN5ZNkYd73eT3kX8Wle2f73SzjWShwZjGBHwasVPr9Wco1eCyuxK037vBWdQHW5QUlTZ4GeKGF9/DIahe6SgLWb7FCNLjeW1PoeXQxhpG5eQw0oLYnhCc=");

            string e1 = pKCS1.Encrypt("hello world!>>>LO*", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string e2 = pKCS1.Encrypt("你好哇，阿鲁哇", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string e3 = pKCS1.Encrypt("来个表情，😍🤦‍♀️🎉💋😉💖💖", System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);

            string d1 = pKCS1.Decrypt(e1, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string d2 = pKCS1.Decrypt(e2, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);
            string d3 = pKCS1.Decrypt(e3, System.Security.Cryptography.RSAEncryptionPadding.OaepSHA256);

            Console.WriteLine(d1);
            Console.WriteLine(d2);
            Console.WriteLine(d3);
        }
    }
}
